package com.example.barcodeapp.adapter.ownadapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.barcodeapp.R;
import com.example.barcodeapp.ui.home.activity.JiaoShiXiangQingJieMianActivity;
import com.example.barcodeapp.ui.home.activity.RiLiActivity;
import com.example.barcodeapp.ui.home.activity.RiLiYueKeJiaoShiLeiBiaoActivituy;
import com.example.barcodeapp.ui.own.activity.XiangQingActivity;
import com.example.barcodeapp.ui.own.bean.PeiLianKeBean;

import java.util.ArrayList;
import java.util.List;

public class AdapterOneDuiOne extends RecyclerView.Adapter<AdapterOneDuiOne.ViewHolder> {
    Context context;

    public AdapterOneDuiOne(Context context) {
        this.context = context;
    }

    private List<PeiLianKeBean.DataEntity> list;

    public AdapterOneDuiOne(Context context, List<PeiLianKeBean.DataEntity> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.adapter_oneduione, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {//textView13
        if (position == 2) {
            holder.textView13.setVisibility(View.GONE);
        }

            holder.textView3.setText(list.get(position).getName());
            holder.textView12.setText(list.get(position).getDengji());
            holder.textView14.setText(list.get(position).getPingfen());
            holder.oneduioneNeirong1.setText(list.get(position).getCoursecate());
            holder.textView15.setText(list.get(position).getPrice());
            holder.oneduioneNeirong3.setVisibility(View.INVISIBLE);
            holder.oneduioneNeirong2.setVisibility(View.INVISIBLE);
            holder.oneduioneNeirong4.setVisibility(View.INVISIBLE);
            holder.yuke.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent instant = new Intent(context, JiaoShiXiangQingJieMianActivity.class);
                    instant.putExtra("data",list.get(position).getId());
                    instant.putExtra("neirong","状态");
                    context.startActivity(instant);
                }
            });
            holder.chakan.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent instant = new Intent(context, RiLiYueKeJiaoShiLeiBiaoActivituy.class);
                    instant.putExtra("data",list.get(position).getId()+"");
                    context.startActivity(instant);
                }
            });



    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView oneduioneImg;
        private TextView textView3;
        private LinearLayout linearLayout3;
        private TextView oneduioneNeirong1;
        private TextView oneduioneNeirong2;
        private TextView oneduioneNeirong3;
        private TextView oneduioneNeirong4;
        private TextView textView12;
        private TextView textView13;
        private ImageView imageView4;
        private TextView textView14;
        private TextView textView15;
        private TextView yuke;
        private TextView chakan;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            oneduioneImg = (ImageView) itemView.findViewById(R.id.oneduione_img);
            textView3 = (TextView) itemView.findViewById(R.id.textView3);
            linearLayout3 = (LinearLayout) itemView.findViewById(R.id.linearLayout3);
            oneduioneNeirong1 = (TextView) itemView.findViewById(R.id.oneduione_neirong1);
            oneduioneNeirong2 = (TextView) itemView.findViewById(R.id.oneduione_neirong2);
            oneduioneNeirong3 = (TextView) itemView.findViewById(R.id.oneduione_neirong3);
            oneduioneNeirong4 = (TextView) itemView.findViewById(R.id.oneduione_neirong4);
            textView12 = (TextView) itemView.findViewById(R.id.textView12);
            textView13 = (TextView) itemView.findViewById(R.id.textView13);
            imageView4 = (ImageView) itemView.findViewById(R.id.imageView4);
            textView14 = (TextView) itemView.findViewById(R.id.textView14);
            textView15 = (TextView) itemView.findViewById(R.id.textView15);
            chakan = (TextView) itemView.findViewById(R.id.yueke);
            yuke = (TextView) itemView.findViewById(R.id.chakan);
        }
    }
}
